import { Geometry } from './geometry'

/**
 * @ClassName point
 * @Description 点
 * @Author xuyizhuo
 * @Date 2024/1/20 14:06
 */
export class Point extends Geometry {
    static RADIUS: number = 10 // 半径，单位为px

    // 点的坐标
    private _x: number
    private _y: number

    constructor(x: number, y: number) {
        super()
        this._x = x
        this._y = y
    }

    // 绘制图形
    draw(ctx: CanvasRenderingContext2D) {
        // 保存当前的绘制状态
        ctx.save()
        ctx.strokeStyle = '#ff0000'
        ctx.fillStyle = '#ff0000'
        ctx.beginPath()
        // 在canvas上绘制圆
        ctx.arc(this._x, this._y, Point.RADIUS, 0, 2 * Math.PI, true)
        ctx.fill()
        ctx.stroke()
        ctx.restore()
    }
}
